package com.mashibing.servicepassengeruser.controller;

import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.request.VerificationCodeDTO;
import com.mashibing.servicepassengeruser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @Autowired
    private UserService userService;


    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        System.out.println(passengerPhone+"shoujihao");
        return userService.loginOrRegister(passengerPhone);
    }

@GetMapping("/user/{phone}")//这里和上边请求路径因为多了一个/所以不一样。
    public ResponseResult getUser(@PathVariable("phone") String passengerPhone){


    System.out.println("需要查询的手机号"+passengerPhone);
    return userService.getUserByPhone(passengerPhone);
    }

}
